package com.zzyl.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import lombok.Getter;

import java.util.EnumSet;
import java.util.Objects;

@Getter
@ApiModel(description = "预约类型")
public enum ReservationType {

    CAN_GUAN("参观预约", 0),
    TAN_WANG("探访预约", 1);

    private String name;
    @JsonValue
    private Integer value;

    ReservationType(String name,Integer value ){
        this.name = name;
        this.value = value;
    }

    public static ReservationType getByValue(Integer value){
        EnumSet<ReservationType> reservationTypes = EnumSet.allOf(ReservationType.class);
        for (ReservationType reservationType : reservationTypes) {
            if(Objects.equals(reservationType.getValue(), value)){
                return reservationType;
            }
        }
        return null;
    }
}